<template>
	<u-navbar :leftIconSize='0' titleStyle="font-size:20px;font-weight:600" :placeholder='true' title="我的"> </u-navbar>
	<view style="margin-top: 15px;font-size: 16px;padding: 0 16px;
font-family: PingFang SC;font-weight:500;color: #333333;" class="white-bg">
		<view class="cell-theme flex-jc-s-b " style="">
			<text>姓名</text>
			<text style="color: #666666;font-size: 14px;font-weight:400;">{{recordData.name || ''}}</text>
		</view>
		<view class="cell-theme flex-jc-s-b border-top-1px-01" style="">
			<text>身份证号</text>
			<text style="color: #666666;font-size: 14px;font-weight:400;">{{recordData.idCard || ''}}</text>
		</view>
		<view class="cell-theme flex-jc-s-b border-top-1px-01" style="">
			<text>手机号</text>
			<text style="color: #666666;font-size: 14px;font-weight:400;">{{recordData.phone || ''}}</text>
		</view>
	</view>
	<view class="butView" @click="exitAction">
		退出登录
	</view>
</template>
<script setup>
	import { onMounted, reactive, ref, defineExpose } from 'vue'
	import { studentDetail } from '@/api/tabBarPages/index.js'
	import { exitLogin } from '@/api/login.js'
	const tabList = ref([{
			label: '模拟考试',
			value: 0,
		},
		{
			label: '自由练习',
			value: 1,
		},
	])
	const exitAction = () => {
		exitLogin({ sessionKey: uni.getStorageSync('token') }).then((res) => {
			if (res.code == 200) {
				uni.showToast({
					mask: true,
					title: res.msg,
					duration: 1200,
					icon: 'none'
				})
				uni.clearStorageSync();
				uni.$u.route({
					type: 'redirect',
					url: 'pages/login/login'
				})
			}
		})
	}
	let recordData = ref({})

	const initTrainPage = () => {
		studentDetail({}).then((res) => {
			recordData.value = res.data || {}
			// console.log(recordData,'recordData')
		})
	}
  defineExpose({
    initData: initData()
  });
  function initData() {
    let token = uni.getStorageSync('token')
    if(token) {
      initTrainPage()
    }
  }
	onMounted(() => {
    // let token = uni.getStorageSync('token')
    // if(token) {
    //   initTrainPage()
    // }

		// testApi({}).then((res) => {})
	})
</script>
<style lang="scss">
	.butView {
		color: #F56C6C;
		margin-top: 15px;
		height: 56px;
		background-color: #fff;
		font-size: 17px;
		line-height: 56px;
		text-align: center;
	}

	.u-button {
		&__text {
			font-size: 17px !important;
		}
	}

	.exitBut {
		width: 80%;
		/* margin: auto; */
		position: absolute;
		width: 18.6rem;
		left: 50%;
		margin-left: -9.3rem;
		bottom: 12rem;
	}
</style>
